<?php

namespace App\Console\Commands;

use App\Admin\Models\Statistic;
use App\Modules\Order\Models\Order;
use Illuminate\Console\Command;

class DeleteUnpaidTimeOutOrders extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'delete_unpaid_orders';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '删除未支付且超过30分钟的订单';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Order::where('status',0)->where('created_at','<',date('Y-m-d H:i:s',strtotime('-30 minutes')))->update(['status'=>-1]);
    }
}
